﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace InsuranceAdjuster.Web
{
    public class Global : System.Web.HttpApplication
    {

        protected void Application_Start(object sender, EventArgs e)
        {
            var MyConnectionString = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/").ConnectionStrings.ConnectionStrings["ApplicationServices"].ConnectionString; 

            try
            {
                using (var MyConnection = new System.Data.SqlClient.SqlConnection(MyConnectionString))
                {
                    MyConnection.Open();
                }
            }
            catch (System.Data.SqlClient.SqlException ex)
            {
                throw new ApplicationException("Cannot connect to the database, make sure you have the database 'InsuranceAdjuster' loaded at '.\\SQLExpress'.  If not, run '\\Lib\\DatabaseSetup\\ResetDatabase.bat'.", ex );
            }
        }

        protected void Session_Start(object sender, EventArgs e)
        {

        }

        protected void Application_BeginRequest(object sender, EventArgs e)
        {

        }

        protected void Application_AuthenticateRequest(object sender, EventArgs e)
        {

        }

        protected void Application_Error(object sender, EventArgs e)
        {

        }

        protected void Session_End(object sender, EventArgs e)
        {

        }

        protected void Application_End(object sender, EventArgs e)
        {

        }
    }
}